{extend name="admin@index_layout"/}
{block name="main"}
<div class="layui-card">
    <div class="layui-card-body">
        <form class="layui-form" method="post" lay-filter="layui-form">
            <div class="layui-tab layui-tab-card">
                <ul class="layui-tab-title">
                    <li class="layui-this">网址规则</li>
                    <li>内容规则</li>
                    <li>高级配置</li>
                </ul>
                <div class="layui-tab-content">
                    <div class="layui-tab-item layui-show">
                        <fieldset class="layui-elem-field">
                            <legend>基本信息</legend>
                            <div class="layui-field-box">
                                <div class="layui-form-item">
                                    <label>采集任务名</label>
                                    <div class="layui-form-field-label">
                                        <input type="text" name="data[name]" required lay-verify="required" placeholder="采集任务名" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label>页面编码</label>
                                    <div class="layui-form-field-label">
                                        <input type="radio" name="data[sourcecharset]" value="utf-8" title="utf-8" checked>
                                        <input type="radio" name="data[sourcecharset]" value="auto" title="自动(会删除HEAD头部)">
                                    </div>
                                </div>
                            </div>
                        </fieldset>
                        <fieldset class="layui-elem-field">
                            <legend>起始页网址</legend>
                            <div class="layui-field-box">
                                <div class="layui-form-item">
                                    <label>网址类型</label>
                                    <div class="layui-form-field-label">
                                        <input type="radio" name="data[sourcetype]" lay-filter="urlType" value="1" title="序列网址" checked>
                                        <input type="radio" name="data[sourcetype]" lay-filter="urlType" value="2" title="多个网页">
                                    </div>
                                </div>
                                <div class="url_type">
                                    <div class="layui-form-item">
                                        <label>采集网址</label>
                                        <div class="layui-form-field-label">
                                            <input type="text" name="urlpage1" placeholder="采集网址" autocomplete="off" class="layui-input">
                                        </div>
                                        <div class="layui-form-mid layui-word-aux">(如：http://bbs.yzncms.com/?index-(*).htm,页码使用(*)做为通配符。</div>
                                    </div>

                                    <div class="layui-form-item">
                                        <div class="layui-inline">
                                            <label class="layui-form-label">页码从</label>
                                            <div class="layui-input-inline">
                                                <input type="text" class="layui-input" name="data[pagesize_start]" placeholder="开始页" value="1">
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">至</label>
                                            <div class="layui-input-inline">
                                                <input type="text" class="layui-input" name="data[pagesize_end]" placeholder="结束页" value="10">
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">页，每次增加</label>
                                            <div class="layui-input-inline">
                                                <input type="text" class="layui-input" name="data[par_num]" placeholder="加 ? 页" value="1">
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-form-item layui-form-text url_type2" style="display:none;">
                                    <label>采集网址</label>
                                    <div class="layui-form-field-label">
                                        <textarea name="urlpage2" placeholder="采集网址" class="layui-textarea"></textarea>
                                    </div>
                                    <div class="layui-form-mid layui-word-aux">每行一条网址</div>
                                </div>
                            </div>
                        </fieldset>
                        <fieldset class="layui-elem-field">
                            <legend>列表页网址和标题</legend>
                            <div class="layui-field-box">
                                <div class="layui-form-item">
                                    <label>切片</label>
                                    <div class="layui-form-field-label">
                                        <input type="text" class="layui-input" name="data[url_range]" placeholder="切片" value="">
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <div class="layui-inline">
                                        <label class="layui-form-label">URL选择器</label>
                                        <div class="layui-input-inline">
                                            <input type="text" class="layui-input" name="data[url_rule1]" placeholder="选择器" value="">
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">属性</label>
                                        <div class="layui-input-inline">
                                            <input type="text" class="layui-input" name="data[url_rule2]" placeholder="属性" value="">
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">内容过滤器</label>
                                        <div class="layui-input-inline">
                                            <input type="text" class="layui-input" name="data[url_rule3]" placeholder="内容过滤器" value="">
                                        </div>
                                    </div>
                                </div>

                                <div class="layui-form-item">
                                    <div class="layui-inline">
                                        <label class="layui-form-label">标题选择器</label>
                                        <div class="layui-input-inline">
                                            <input type="text" class="layui-input" name="data[url_rule4]" placeholder="选择器" value="">
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">属性</label>
                                        <div class="layui-input-inline">
                                            <input type="text" class="layui-input" name="data[url_rule5]" placeholder="属性" value="">
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">内容过滤器</label>
                                        <div class="layui-input-inline">
                                            <input type="text" class="layui-input" name="data[url_rule6]" placeholder="内容过滤器" value="">
                                        </div>
                                    </div>
                                </div>


                                <div class="layui-form-item">
                                    <div class="layui-inline">
                                        <label class="layui-form-label">网址中必须包含</label>
                                        <div class="layui-input-inline">
                                            <input type="text" class="layui-input" name="data[url_contain]" value="">
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">网址中不得包含</label>
                                        <div class="layui-input-inline">
                                            <input type="text" class="layui-input" name="data[url_except]" value="">
                                        </div>
                                    </div>
                                </div>

                            </div>
                        </fieldset>
                    </div>
                    <div class="layui-tab-item">
                        <div class="layui-form-item layui-form-text">
                            <table class="layui-form-field-label layui-table fieldlist border-none" data-name="data[customize_config]" data-id="customize_config" data-template="true" data-tag="tr">
                                <tr>
                                    <td>标题</td>
                                    <td>字段名</td>
                                    <td>选择器</td>
                                    <td>属性</td>
                                    <td>固定值</td>
                                    <td>内容过滤器</td>
                                    <td width="60">移动/删除</td>
                                </tr>
                                <tr><td colspan="10"><button type="button" class="layui-btn btn-append">追加</button></td></tr>
                            </table>
                            <textarea name="data[customize_config]" class="layui-textarea layui-hide"></textarea>
                        </div>
                        <script type="text/html" id="customize_configTpl">
                            <tr class="layui-form-item rules-item">
                                {{# layui.each(d.lists, function(index, item) { }}
                                <td>
                                    <input type="text" class="layui-input" name="{{item.name}}[{{item.index}}][title]" placeholder="标题" value="{{item.row.title|| ''}}" />
                                </td>
                                <td>
                                    <input type="text" class="layui-input" name="{{item.name}}[{{item.index}}][name]" placeholder="字段名" value="{{item.row.name|| ''}}" />
                                </td>
                                <td>
                                    <input type="text" class="layui-input" name="{{item.name}}[{{item.index}}][selector]" placeholder="选择器" value="{{item.row.selector|| ''}}" />
                                </td>
                                <td>
                                    <input type="text" class="layui-input" name="{{item.name}}[{{item.index}}][attr]" placeholder="属性" value="{{item.row.attr|| ''}}" />
                                </td>
                                <td>
                                    <input type="text" class="layui-input" name="{{item.name}}[{{item.index}}][value]" placeholder="固定值" value="{{item.row.value|| ''}}" />
                                </td>

                                <td>
                                    <input type="text" class="layui-input" name="{{item.name}}[{{item.index}}][filter]" placeholder="内容过滤器" value="{{item.row.filter|| ''}}" />
                                </td>
                                <td>
                                    <button type="button" class="layui-btn layui-btn-danger btn-remove layui-btn-xs"><i class="iconfont icon-close"></i></button>
                                    <button type="button" class="layui-btn btn-dragsort layui-btn-xs"><i class="iconfont icon-yidong"></i></button>
                                </td>
                                {{# }); }}
                            </tr>
                        </script>
                    </div>
                    <div class="layui-tab-item">
                        <div class="layui-form-item">
                            <label>下载图片</label>
                            <div class="layui-form-field-label">
                                <input type="radio" name="data[down_attachment]" value="1" title="是">
                                <input type="radio" name="data[down_attachment]" value="0" title="否" checked>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label>图片水印</label>
                            <div class="layui-form-field-label">
                                <input type="radio" name="data[watermark]" value="1" title="是">
                                <input type="radio" name="data[watermark]" value="0" title="否" checked>
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item layer-footer">
                        <div class="">
                            <button class="layui-btn" lay-submit>立即提交</button>
                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                        </div>
                    </div>
                </div>
        </form>
    </div>
</div>
{/block}
{block name="script"}
<script type="text/javascript">
    layui.use(['form','yznForm'], function() {
        var form = layui.form,
            formData = [],
            yznForm = layui.yznForm;

        yznForm.listen();
        form.on('radio(urlType)', function(data) {
            if (2 == data.value) {
                $('.url_type').hide();
                $('.url_type2').show();
            }
            if (1 == data.value) {
                $('.url_type').show();
                $('.url_type2').hide();
            }
        });
    });
</script>
{/block}